// https://www.alibabacloud.com/help/zh/doc-detail/32077.htm
const OSS = require('ali-oss');
const STS = OSS.STS;
const sts = new STS({
  accessKeyId: 'LTAIsy9rW3uJjbgW',
  accessKeySecret: 'fyLMwvs1p5hPyBWqILJdCXTJBH2nGN'
});

const policy = {
  Statement: [
    {
      Action: ['oss:*'],
      Effect: 'Allow',
      Resource: ['acs:oss:*:*:liuliu-game-box/*']
    }
  ],
  Version: '1'
};

async function genToken() {
  const token = await sts.assumeRole('acs:ram::1770832531740838:role/ossar', policy, 15 * 60, 'test');
  return token;
}

module.exports = genToken;
